<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html >
<html lang="en">
<head>
    <%@include file="../common/includeBaseSet.jsp" %>
    <%@include file="../common/includeSystemSet.jsp" %>
    <%@include file="../common/operation_forbid.jsp" %>
    <%@include file="../common/jsVersion.jsp" %>
    <style type="text/css">
        a{cursor:pointer}
        .table.table-bordered thead tr th {
            vertical-align:middle;
            white-space:nowrap;
            min-width:100px;

        }
    </style>
</head>
<body onload="getSignedInfoList()">
<div class="page-content" style="overflow-x:scroll;">
    <form id="baseForm" class="form-horizontal">
        <input type='hidden' class='pageNum' name='pageNum' value='1'/>
        <input type='hidden' class='pageSize' name='pageSize' value='10'/>
        <div class="col-xs-12 panel panel-default">
            <div style="margin-top:1%">
                <div class="col-xs-2" style="width: 27%">
                    <div class="form-group">
                        <label class="col-xs-5 control-label" style="width: 20%;">组团:</label>
                        <div class="col-xs-7">
                            <select name="premisesId" id="premisesId" class="form-control" style="width:100%" >
                                <c:choose>
                                    <c:when test="${premisesList != null && premisesList != ''}">
                                        <option value="">--全部--</option>
                                        <c:forEach items="${premisesList}" var="list">
                                            <option value="${list.id}">${list.groupName}</option>
                                        </c:forEach>
                                    </c:when>
                                </c:choose>
                            </select>
                            <%-- <input class="form-control" type="text" name="premisesSecName" id="premisesSecName" />--%>
                        </div>
                    </div>
                </div>
                <div class="col-xs-8" style="display: flex;flex-wrap: wrap;">
                    <div class="form-group" style="position:relative">
                        <label class="col-xs-3 control-label">签约时间:</label>
                        <div class="col-xs-4">
                            <input class="form-control" type="text" name="strTime" id="strTime" onClick="WdatePicker()"/>
                        </div>
                        <div class="col-xs-4">
                            <input class="form-control" type="text" name="endTime" id="endTime" onClick="WdatePicker()"/>
                        </div>
                        <div style="position: absolute;top: 19%;left: 58%;">-</div>
                    </div>
                <div class="form-group" style="display: flex;flex-direction: row;margin-left: 160px;">
                    <div style="margin-left:40px">
                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:70px;"
                                title="查询" type="button" onclick="JY.Page.jump('baseForm',1,'getSignedInfoList')">
                            <i class="icon-search bigger-110 icon-only">搜索</i>
                        </button>
                    </div>

                    <div style="margin-left:40px">
                        <button id='exportBtn' class="btn btn-info  btn-xs"  style="width:70px;background: blue"
                                title="导出" type="button" onclick="exportCustomerInfo()">
                            <i class=" bigger-110 icon-only">导出</i>
                        </button>
                    </div>

                    <div style="margin-left:40px">
                        <button id='cleanBtn' class="btn btn-info  btn-xs"  style="width:70px;background: blue"
                                title="清空" type="button" onclick="cleanQuery()">
                            <i class=" bigger-110 icon-only">清空</i>
                        </button>
                    </div>
                </div>

            </div>
        </div>
    </form>
    <div class="col-xs-12">
        <table id="baseTable" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th class="center" style="min-width:200px;">项目名称</th>
                <th class="center" style="min-width:200px;">分期</th>
                <th class="center" style="min-width:420px;">房间</th>
                <th class="center">业态</th>
                <th class="center">房号</th>
                <th class="center">合同类型</th>
                <th class="center" >付款方式</th>
                <th class="center">客户姓名</th>
                <th class="center">置业顾问</th>
                <th class="center">销售团队</th>
                <th class="center">签约日期</th>
                <th class="center">网签日期</th>

                <th class="center">分期款合计</th>
                <th class="center">分期款欠款</th>

                <th class="center">垫付首期合计</th>
                <th class="center">垫付首期欠款</th>

                <th class="center">第一笔应收时间</th>
                <th class="center">第一笔应收金额</th>
                <th class="center">第一笔欠款</th>

                <th class="center">第二笔应收时间</th>
                <th class="center">第二笔应收金额</th>
                <th class="center">第二笔欠款</th>

                <th class="center">第三笔应收时间</th>
                <th class="center">第三笔应收金额</th>
                <th class="center">第三笔欠款</th>

                <th class="center">第四笔应收时间</th>
                <th class="center">第四笔应收金额</th>
                <th class="center">第四笔欠款</th>

                <th class="center">第五笔应收时间</th>
                <th class="center">第五笔应收金额</th>
                <th class="center">第五笔欠款</th>
            </tr>
            </thead>
            <tbody><!-- 内容 --></tbody>
        </table>
        <div class="row">
            <div class="col-sm-8">
                <!--设置分页位置-->
                <div id="pageing" class="dataTables_paginate paging_bootstrap">
                    <ul class="pagination"></ul>
                </div>
            </div>
        </div>
    </div>
    <!-- #dialog-confirm -->
    <%@include file="../common/dialog.jsp"%>
</div>
</body>
<script type="text/javascript">

    //查询列表
    function getSignedInfoList(){
        var loadIndex = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        JY.Ajax.doRequest("baseForm",jypath +'/marketing/businessChange/queryPaymentStagesBaseInfo',null,function(data){
            $("#baseTable tbody").empty();
            var page = data.obj;
            if(page == null ){
                html+="<tr><td colspan='8' class='center'>没有相关数据</td></tr>";
                $("#baseTable tbody").append(html);
                $("#pageing ul").empty();//清空分页
                layer.closeAll('loading');
                return false;
            }
            //分页数据
            var pageNum = page.pageNumber, pageSize = page.pageSize, totalRecord = page.total;
            var html = "";
            var results = page.rows;
            if(results == null || results.length <= 0){
                html+="<tr><td colspan='8' class='center'>没有相关数据</td></tr>";
                $("#baseTable tbody").append(html);
                $("#pageing ul").empty();//清空分页
                layer.closeAll('loading');
                return false;
            }

            var leng=(pageNum-1)*pageSize;//计算序号
            for(var i = 0;i<results.length;i++){
                var info = results[i];
                var content;
                if(info.content){
                    content = info.content;
                }else{
                    content = '';
                }
                html += "<tr>";
                html += "<td class='center'>" + info.projectName + "</td>";
                html += "<td class='center'>" + info.premisesName + "</td>";
                html += "<td class='center'>" + info.combinedName + "</td>";
                html += "<td class='center'>" + info.industMark + "</td>";
                html += "<td class='center'>" + info.buildingName + "-" + info.roomName + "</td>";
                html += "<td class='center'>" + info.contactType + "</td>";
                html += "<td class='center'>首付分期-" + info.paymentMethod + "</td>";
                if(info.customerFamilyName != null){
                    html += "<td class='center'>" + info.customerName+";"+info.customerFamilyName + "</td>";
                }else{
                    html += "<td class='center'>" + info.customerName+ "</td>";
                }

                html += "<td class='center'>" + info.agentName + "</td>";
                html += "<td class='center'>" + info.groupName + "</td>";

                html += "<td class='center'>" + JY.Date.Format(info.signDate, "yyyy-MM-dd") + "</td>";
                html += "<td class='center'>" + JY.Date.Format(info.signDate, "yyyy-MM-dd") + "</td>";
                html += "<td class='center'>" + info.totalNeed + "</td>";
                html += "<td class='center'>" + (info.totalNeed-info.totalHave) + "</td>";
                html += "<td class='center'>" + info.totalNeedAdvance + "</td>";
                html += "<td class='center'>" + (info.totalNeedAdvance-info.totalHaveAdvance) + "</td>";
                if(info.needTime1 != null){
                    html += "<td class='center'>" + JY.Date.Format(info.needTime1, "yyyy-MM-dd") + "</td>";
                }else{
                    html += "<td class='center'></td>";
                }
                html += "<td class='center'>" + info.needAmt1 + "</td>";
                html += "<td class='center'>" + info.haveAmt1 + "</td>";

                if(info.needTime2 != null){
                    html += "<td class='center'>" + JY.Date.Format(info.needTime2, "yyyy-MM-dd") + "</td>";
                }else{
                    html += "<td class='center'></td>";
                }
                html += "<td class='center'>" + info.needAmt2 + "</td>";
                html += "<td class='center'>" + info.haveAmt2 + "</td>";

                if(info.needTime3 != null){
                    html += "<td class='center'>" + JY.Date.Format(info.needTime3, "yyyy-MM-dd") + "</td>";
                }else{
                    html += "<td class='center'></td>";
                }
                html += "<td class='center'>" + info.needAmt3 + "</td>";
                html += "<td class='center'>" + info.haveAmt3 + "</td>";

                if(info.needTime4 != null){
                    html += "<td class='center'>" + JY.Date.Format(info.needTime4, "yyyy-MM-dd") + "</td>";
                }else{
                    html += "<td class='center'></td>";
                }
                html += "<td class='center'>" + info.needAmt4 + "</td>";
                html += "<td class='center'>" + info.haveAmt4 + "</td>";

                if(info.needTime5 != null){
                    html += "<td class='center'>" + JY.Date.Format(info.needTime5, "yyyy-MM-dd") + "</td>";
                }else{
                    html += "<td class='center'></td>";
                }
                html += "<td class='center'>" + info.needAmt5 + "</td>";
                html += "<td class='center'>" + info.haveAmt5 + "</td>";

                html += "</tr>";
            }
            $("#baseTable tbody").append(html);
            JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"getSignedInfoList");
            layer.closeAll('loading');
        });
    }


    //导出列表
    function exportCustomerInfo(){
        // JY.Model.loading('数据加载中...')
        var premisesId = $("#premisesId").val();
        var strTime = $("#strTime").val();
        var endTime = $("#endTime").val();
        location.href =  '${jypath}/marketing/businessChange/paymentStagesExport?premisesId='+premisesId+'&strTime='+strTime+'&endTime='+endTime;

        /*layer.open({
            type:2,
            title: "导出",
            closeBtn: 2,
            shadeClose: true,
            area: ['550px', '180px'],
            fix: false, //不固定
            content: url,
            success: function (index, layero) {
                layer.closeAll('loading');
                JY.Model.loadingClose();
            }
        });*/
        /*$.ajax({
            url: url,
            method: 'get',
            success: function (e) {
                JY.Model.loadingClose();
            }
        });*/
    }


    //解决选中input框按回车时会刷新页面的问题
    function ClearSubmit(e) {
        if (e.keyCode == 13) {
            return false;
        }
    }

    //
    function cleanQuery(){
        $("#premisesId").val("");
        $("#strTime").val("");
        $("#endTime").val("");
    }
</script>
</html>